package lyl.http.httpclient;

import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;

/**
 * 
 * @author Liu Yulong
 */
public class DownLoad {

    public static  byte[]  downloadURL(String url) {
        HttpClient client = new HttpClient();
        GetMethod get = new GetMethod(url);
        try {
            client.executeMethod(get);
            byte[] bytes = get.getResponseBody();
            FileOutputStream stream = new FileOutputStream("d:\\sss.rar");
            stream.write(bytes);
            return bytes;
        }
        catch (HttpException e) {
            e.printStackTrace();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    public static void main(String[] args) {
        //consumeByWSDLClient();
        downloadURL("http://www.xdowns.com/soft/xdowns.asp?softid=41397&downid=57&id=43920");
    }
    
}
